
import Vue from 'vue'
import VueRouter from 'vue-router'
import Router from 'vue-router'

Vue.use(Router)
Vue.use(VueRouter)

/* Layout */
import Layout from '@/layout'

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */



export const constantRoutes = [
  //登录
{
  path: '/login',
  component: () => import('@/views/login/index'),
  hidden: true
},
//404
{
  path: '/404',
  component: () => import('@/views/404'),
  hidden: true
},
//首页
{
  path: '/',
  component: Layout,
  hidden:true,
  redirect: '/bankCardAsile/GBO_card',
  name: 'Dashboards',
  children: [{
    path: 'dashboard',
    name: 'Dashboard',
    redirect: '/bankCardAsile/GBO_card',
    component: () => import('@/views/dashboard/index'),
    meta: {
      title: '首页',
      icon: 'el-icon-s-home'
    }
  }]
},
//卡配置
{
  path: '/bankCardAsile',
  component: Layout,
  redirect: '/bankCardAsile/GBO_card',
  name: 'BankCardAsile',
  meta: {
    title: 'IP管理',
    icon: 'el-icon-bank-card'
  },
  children: [
    // {
    //   path: 'IpAdministration',
    //   name: 'IpAdministration',
    //   component: () => import('@/views/IP/ipAdministration'),
    //   // component: () => import('@/views/systems/'),
    //   meta: {
    //     title: 'IP管理',
    //     icon: 'el-icon-date'
    //   }
    // },
    {
      path: 'GBO_card',
      name: 'GBO_card',
      component: () => import('@/views/cardConfig/GBO_card.vue'),
      // component: () => import('@/views/systems/'),
      meta: {
        title: '卡配置管理',
        icon: 'el-icon-date'
      }
    },
    {
      path: 'add_IP',
      name: 'add_IP',
      component: () => import('@/views/cardConfig/page/addIP.vue'),
      // component: () => import('@/views/systems/'),
      meta: {
        title: '添加IP',
        icon: 'el-icon-date'
      },
      hidden:true
    },
    {
      path: 'renew',
      name: 'renew',
      component: () => import('@/views/cardConfig/page/renewIpAmountDetail.vue'),
      // component: () => import('@/views/systems/'),
      meta: {
        title: '续费管理',
        icon: 'el-icon-date'
      },
      hidden:true
    },
    {
      path: 'noticePage',
      name: 'noticePage',
      component: () => import('@/views/cardConfig/page/noticePage.vue'),
      // component: () => import('@/views/systems/'),
      meta: {
        title: '协查通知',
        icon: 'el-icon-date'
      },
      hidden:true
    },
    {
      path: 'bankPayCardGroup/:id',
      name: 'bankPayCardGroup',
      component: () => import('@/views/cardConfig/page/bankPayCardGroup.vue'),
      // component: () => import('@/views/systems/'),
      meta: {
        title: '小组详情',
        icon: 'el-icon-date'
      },
      hidden:true
    }
  ]
},
//统计报表
{
  path: '/statisticalReport',
  component: Layout,
  redirect: '/statisticalReport/incomeStatistics',
  name: 'BankCardAsiles',
  meta: {
    title: '统计报表',
    icon: 'el-icon-bank-card'
  },
  children: [
    {
      path: 'incomeStatistics',
      name: 'incomeStatistics',
      component: () => import('@/views/statisticalReport/incomeStatistics.vue'),
      // component: () => import('@/views/systems/'),
      meta: {
        title: '收入统计',
        icon: 'el-icon-date'
      }
    },
    {
      path: 'ipOrderPay',
      name: 'ipOrderPay',
      component: () => import('@/views/statisticalReport/ipOrderPay.vue'),
      // component: () => import('@/views/systems/'),
      meta: {
        title: '支出统计',
        icon: 'el-icon-date'
      }
    },
    {
      path: 'payStatistics',
      name: 'payStatistics',
      component: () => import('@/views/statisticalReport/purchaseStatistics.vue'),
      // component: () => import('@/views/systems/'),
      meta: {
        title: '财务统计',
        icon: 'el-icon-date'
      }
    }
  ]
},
//权限管理
{
  path: '/systems',
  component: Layout,
  redirect: '/systems/authManage',
  name: 'systems',
  meta: {
    title: '管理员管理',
    icon: 'el-icon-bank-card'
  },
  children: [{
    path: 'role',
    name: 'Role',
    component: () => import('@/views/systems/role'),
    meta: {
      title: '管理员管理',
      icon: 'el-icon-user'
    }
  }, {
    path: 'authManage',
    name: 'AuthManage',
    component: () => import('@/views/systems/authManage'),
    meta: {
      title: '权限管理',
      icon: 'tree'
    }
  }, {
    path: 'authConfig',
    name: 'AuthConfig',
    component: () => import('@/views/systems/authConfig'),
    meta: {
      title: '角色配置',
      icon: 'tree'
    },
    // hidden:true
  },
]
},
//系统管理
{
  path: '/systemsManage',
  component: Layout,
  redirect: 'course',
  name: 'systemsManage',
  meta: {
    title: '系统管理',
    icon: 'el-icon-info'
  },
  children: [{
    path: '/systemsManage/course',
    name: 'course',
    component: () => import('@/views/systemsManage/course.vue'),
    meta: {
      title: '发布教程',
      icon: 'el-icon-upload2'
    }
  }, {
    path: 'download',
    name: 'download',
    component: () => import('@/views/systemsManage/download.vue'),
    meta: {
      title: '下载管理',
      icon: 'el-icon-upload2'
    }
  }, {
    path: 'notice',
    name: 'notice',
    component: () => import('@/views/systemsManage/notice.vue'),
    meta: {
      title: '公告管理',
      icon: 'el-icon-upload2'
    },
    // hidden:true
  },
  {
    path: 'detailCourse/:id',
    name: 'detailCourse',
    component: () => import('@/views/systemsManage/detailCourse.vue'),
    // component: () => import('@/views/systems/'),
    meta: {
      title: '教程详情',
      icon: 'el-icon-date'
    },
    hidden:true
  },
  {
    path: 'editCourse/:id',
    name: 'editCourse',
    component: () => import('@/views/systemsManage/page/editCourse.vue'),
    // component: () => import('@/views/systems/'),
    meta: {
      title: '教程编辑',
      icon: 'el-icon-date'
    },
    hidden:true
  }]
},
// {
//   path: '/example',
//   component: Layout,
//   redirect: '/example/table',
//   name: 'Example',
//   meta: {
//     title: 'Example',
//     icon: 'el-icon-s-help'
//   },
//   hidden:true,
//   children: [{
//       path: 'table',
//       name: 'Table',
//       component: () => import('@/views/table/index'),
//       meta: {
//         title: 'Table',
//         icon: 'table'
//       }
//     },
//     {
//       path: 'tree',
//       name: 'Tree',
//       component: () => import('@/views/tree/index'),
//       meta: {
//         title: 'Tree',
//         icon: 'tree'
//       }
//     }
//   ]
// },


{
  path: '/form',
  component: Layout,
  hidden:true,
  children: [{
    path: 'index',
    name: 'Form',
    component: () => import('@/views/form/index'),
    meta: {
      title: 'Form',
      icon: 'form'
    }
  }]
},
// {
//   path: 'external-link',
//   component: Layout,
//   children: [{
//     path: 'https://panjiachen.github.io/vue-element-admin-site/#/',
//     meta: {
//       title: 'External Link',
//       icon: 'link'
//     },
//     hidden: false
//   }]
// },

// 404 page must be placed at the end !!!
{
  path: '*',
  redirect: '/404',
  hidden: true
}]


const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({
    y: 0
  }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
